<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./css/bootstrap.min.css">
  <!-- <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"></script> -->
  <script src="./js/bootstrap.bundle.min.js"></script>
  <title>订单管理</title>
</head>
<?php
    include 'SqlConnect.php';
?>
<body>
  <div class="container text-center">
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-sm navbar-primary text-muted justify-content-center"
      style="background-color: #e3f2fd;" data-bs-theme="light">
      <!-- Brand -->
      <a class="navbar-brand" href="#">Logo</a>
      <!-- Links -->
      <ul class="navbar-nav">
        <!-- Dropdown -->
        <!-- <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-bs-toggle="dropdown">
          订单管理
        </a>
        <div class="dropdown-menu">
          <a class="dropdown-item" href="/manager.html">查询订单</a>
          <a class="dropdown-item" href="/addOrder.php">增加订单</a>
          <a class="dropdown-item" href="#">修改订单</a>
          <a class="dropdown-item" href="#">删除订单</a>
        </div>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-bs-toggle="dropdown">
          用户管理
        </a>
        <div class="dropdown-menu">
          <a class="dropdown-item" href="#">查询用户</a>
          <a class="dropdown-item" href="#">增加用户</a>
          <a class="dropdown-item" href="#">修改用户</a>
          <a class="dropdown-item" href="#">删除用户</a>
        </div>
      </li> -->
        <li class="nav-item">
          <a class="nav-link active" href="/manager.html">查询订单</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/addOrder.html">增加订单</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">修改订单</a>
        </li>

      </ul>
    </nav>
    <div class="container">
        <!-- 显示用户列表 -->
        <h2>用户列表</h2>
        <table border="1">
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>邮箱</th>
                <th>操作</th>
            </tr>
            <?php if ($result->num_rows > 0): ?>
                <?php while($row = $result->fetch_assoc()): ?>
                    <tr>
                        <td><?php echo $row['id']; ?></td>
                        <td><?php echo $row['name']; ?></td>
                        <td><?php echo $row['age']; ?></td>
                        <td><?php echo $row['email']; ?></td>
                        <td>
                            <!-- 编辑用户表单 -->
                            <form method="post" action="" style="display:inline;">
                                <input type="hidden" name="action" value="update">
                                <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                                <input type="text" name="name" value="<?php echo $row['name']; ?>">
                                <input type="number" name="age" value="<?php echo $row['age']; ?>">
                                <input type="email" name="email" value="<?php echo $row['email']; ?>">
                                <input type="submit" value="更新">
                            </form>
                            <!-- 删除用户表单 -->
                            <form method="post" action="" style="display:inline;">
                                <input type="hidden" name="action" value="delete">
                                <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                                <input type="submit" value="删除">
                            </form>
                        </td>
                    </tr>
                <?php endwhile; ?>
            <?php else: ?>
                <tr>
                    <td colspan="5">没有记录</td>
                </tr>
            <?php endif; ?>
        </table>
        </div>

  </div>
</body>

</html>